<?php
// PHP Proxy example for Yahoo! Web services. 
// Responds to both HTTP GET and POST requests
//
// Author: Jason Levitt
// December 7th, 2005
//

// Allowed hostname (api.local and api.travel are also possible here)
define ('HOSTNAME', 'http://www.paris.free.fr/');

// Get the REST call path from the AJAX application
// Is it a POST or a GET?
if (isset($_POST['yws_path'])){
	$path = $_POST['yws_path'] ;
	}else{
	$path = $_GET['yws_path'] ;
	}
//je change, voir si les undefined index viennent de la !	
//$path = ($_POST['yws_path']) ? $_POST['yws_path'] : $_GET['yws_path'];

// SR $url = HOSTNAME.$path;
$url = $path;


// Open the Curl session
$session = curl_init($url);

// If it's a POST, put the POST data in the body
if (isset($_POST['yws_path'])) {
	$postvars = '';
	while ($element = current($_POST)) {
		$postvars .= key($_POST).'='.$element.'&';
		next($_POST);
	}
	curl_setopt ($session, CURLOPT_POST, true);
	curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
}

// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

// Make the call
$xml = curl_exec($session);

// The web service returns XML. Set the Content-Type appropriately
// SR header("Content-Type: text/xml");

echo $xml;
curl_close($session);

?>
